Skip to content

Potential fix for code scanning alert no. 901: Workflow does not contain permissions#584

Merged
aurelianware merged 4 commits intomainfrom
alert-autofix-901
Mar 30, 2026
Merged

Potential fix for code scanning alert no. 901: Workflow does not contain permissions#584
aurelianware merged 4 commits intomainfrom
alert-autofix-901

Conversation

@aurelianware
Copy link
Copy Markdown
Owner

@aurelianware aurelianware commented Mar 27, 2026

Potential fix for https://github.com/aurelianware/cloudhealthoffice/security/code-scanning/901

The fix explicitly sets permissions: blocks per-job to restrict the default GITHUB_TOKEN scope to the least privileges required for each job, preserving existing functionality.

Concretely, in .github/workflows/azure-static-web-apps-agreeable-meadow-0da15b31e.yml:

  • build_and_deploy_job receives:

    permissions:
      contents: read
      pull-requests: write

    The pull-requests: write scope is required for Azure/static-web-apps-deploy@v1 to post and update PR comments via repo_token.

  • close_pull_request_job receives:

    permissions:
      contents: read

    This job only closes the staging environment and does not require PR write access.

Scoping permissions per-job (rather than at the workflow level) ensures each job holds only the minimum privileges it actually needs.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…ain permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Aurelianware <markus@aurelianware.com>
@aurelianware
Copy link
Copy Markdown
Owner Author

@copilot can you fix the lint check that’s failing

@aurelianware aurelianware marked this pull request as ready for review March 27, 2026 18:41
Copilot AI review requested due to automatic review settings March 27, 2026 18:41
Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 27, 2026

@copilot can you fix the lint check that’s failing

Fixed in commit 6b0fc8f. The yamllint failure was caused by Windows-style CRLF line endings in the workflow file — converted them to LF, which resolves the [error] wrong new line character: expected \n error.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an explicit permissions block to the Azure Static Web Apps CI/CD workflow to address code scanning alert #901 by restricting default GITHUB_TOKEN privileges.

Changes:

  • Add workflow-level permissions with contents: read to limit GITHUB_TOKEN scope.

Comment on lines +12 to +13
permissions:
contents: read
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new workflow-level permissions restricts GITHUB_TOKEN to contents: read, but this workflow passes secrets.GITHUB_TOKEN as repo_token to Azure/static-web-apps-deploy@v1 (notably for PR integrations/PR comments). With only contents: read, the action will no longer be able to create/update PR comments or other PR metadata, changing existing behavior. Consider adding the minimal additional scopes required (typically pull-requests: write, and scope it per-job if you want close_pull_request_job to remain read-only).

Copilot uses AI. Check for mistakes.
Signed-off-by: Aurelianware <markus@aurelianware.com>
@aurelianware
Copy link
Copy Markdown
Owner Author

@copilot apply changes based on the comments in this thread

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 30, 2026

@copilot apply changes based on the comments in this thread

Done in commit de46876. Replaced the workflow-level permissions: contents: read with per-job blocks — build_and_deploy_job gets contents: read + pull-requests: write (preserving PR comment functionality), while close_pull_request_job keeps contents: read only.

@aurelianware aurelianware merged commit 7ef451c into main Mar 30, 2026
48 checks passed
@aurelianware aurelianware deleted the alert-autofix-901 branch March 30, 2026 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants